import {
  saveMaterial,
  saveMaterialRepeat,
  deleteMaterial,
  saveMaterialCustomer
, getAllMaterialByApplyId } from '@/api/accept/aprv_process_materials'
import { deleteCustomer, saveCustomer, queryCustomerMaterialByApplyid } from '@/api/accept/aprv_materials_customer'

import { findAllOptionsByApplyid } from '@/api/accept/aprv_materials_options'

import { APP_USER, APP_DEPT } from '@/store/mutation-types.js'
import storage from 'store'
import { Tp_accept, Tp_hear, Tp_execute, Tp_proctypeEnum } from '@/enumeration/Tp_proctype'
import { Tp_procmaterialValue, Tp_procmaterial_decision_asynapprove } from '@/enumeration/Tp_procmaterial'
import { kkfilePreview, webofficeEdit } from '@/utils/util.js'
import { nanoid } from 'nanoid'
import { startBusinessProced } from '@/api/accept/business_Approve'
import { FILETYPE, FILESIZE } from '@/store/mutation-types'
import { viewApl_admre_audit, getLastChildAudit, updatesIscitymanager } from '@/api/accept/apl_admre_audit'
import { getByInstids } from '@/api/apply/apl_main'
import { passRecordExecute } from '@/api/accept/process_approve.js'
import { updateFilename } from '@/api/accept/aprv_materials_options'
export const ProcedureMinxin = {
  // 当前页面注入路由重加载
  inject: ['reload'],
  props: {
    applyid: {
      type: String,
      required: true
    },
    busiKey: {
      type: Number,
      required: true
    },
    category: {
      type: String
    },
    btnLabel: {
      type: String,
      required: false,
      default: () => {
        return '答复'
      }
    },
    isEditModel: {
      type: Boolean,
      default: false,
      required: true
    },
    processinstanceid: {
      type: String,
      required: false
    },
    sonStatus: {
      type: Array,
      required: false
    },
    decisiontype: {
      type: Number,
      required: false
    },
    reason: {
      type: String,
      required: false
    }
  },
  data () {
    return {
      newFilename: '',
      Tp_procmaterial: undefined,
      Tp_proctypeEnum: Tp_proctypeEnum,
      typeEnum: {}, // 当前的类型
      fileList: [], // 文件列表
      uploadFileType: null, // 上传文件的类型
      isMultiUpload: true, // 上传方式
      fileItem: [],
      // {
      //   fileName: undefined,
      //   fileType: undefined,
      //   isMultiUpload: undefined,
      //   fileList: [{
      //     materialId: undefined,
      //     name : undefined,
      //     status: undefined,
      //     uid: undefined,
      //     url:undefined,
      //     isEditor: undefined,
      //   }],
      //   required: undefined,
      //   isCustomer: undefined,
      //   isSaved: undefined,
      //   isUpdated: undefined,
      // }
      busiType: undefined,
      busiName: undefined,
      queryParam: {
        applyid: ''
      },
      loading: false,
      processLoading: false,
      currentUser: storage.get(APP_USER), // 登录人信息
      currentDept: storage.get(APP_DEPT), // 登录人部门
      acceptFileType: FILETYPE,
      labelTitle: '',
      operateBtnShow: true, // 操作按钮展示
      uploadBtnShow: true, // 上传按钮展示
      currentSonstatus: '', // 当前的子流程状态
      customerMaterials: [], // 该类型下的自定义材料
      spinning: false, // 加载框
      operateBtnDisabled: true, // 特殊情况限制按钮
      materialOptionList: [], // 表单生成的材料文件
      selectedOption: {}, // 选中的材料的表单配置
      allFileList: [], // 全部的文件
      childAdmreAudit: {}, // 子流程流程记录  
      isMainProcess: undefined, // 是否是主流程
      isCitymanager: undefined, // 是否市领导审批
      showCitymanager: false // 是否显示市领导审批文件项目
    }
  },
  components: {
    MultiUploadProduce: () => import('@/views/materials/multiUpload/MultiUploadProduce'),
    MaterialVersion: () => import('@/views/materials/MaterialVersion')
  },
  methods: {

    handleDoubleClick(fileItem, index) {
      console.log('sssss')
      // 处理双击文件名的逻辑，例如进入编辑模式
      //把所有材料的编辑开关都设为false
      this.fileItem.forEach((files,index) => {
        files.fileList.forEach((file,index) => {
          file.isEditor = false;
        }) 
        
      });
      //将材料名先复制给 newFilename 双向绑定到 编辑框上
      this.newFilename = fileItem.filename;
      fileItem.isEditor = true; // 进入编辑模式
      //自动获取焦点
      this.$nextTick(() => {
      this.$refs[`input${index}`].forEach(e => {
        e.focus()
      })
      })  
    },
    saveFileName(fileItem) {
      // 保存文件名的逻辑
      fileItem.filename = this.newFilename;
      updateFilename(fileItem.id,fileItem.filename);
      this.fileItem.forEach((files,index) => {
        files.fileList.forEach((file,index) => {
          if (file.id == fileItem.id) {
            file = fileItem
            this.$set(file, 'isEditor', false)
          }
          this.$set(file, 'fileName', this.newFilename)
        }) 
        this.$set(this.fileItem, index, files)  
      });
    },
    // 在 saveFileName 方法中更新文件名并退出编辑模式

    handleClick(fileItem, index) {  
      // 模拟双击事件
      if (this.clickTimeout) {
        clearTimeout(this.clickTimeout);
        this.clickTimeout = null;
        this.handleDoubleClick(fileItem, index);
      } else {
        this.clickTimeout = setTimeout(() => {
          this.clickTimeout = null;
          this.fileView(fileItem);
        }, 300); // 这里的时间间隔可以根据实际情况调整
      }
    },


    async initParam () {
      // 通过传入的类型来获取对应的数据
      this.spinning = true
      this.initTypeEnum()
      await this.setIsMainProcess()
      await this.resetMaterialType()
      this.initComponent()
    },

    initComponent () {
      // this.component = () => import('@/views/handleCase/base/component/BaseCaseHandle')
      // this.updateComponent = () => import('@/views/handleCase/base/component/BaseCaseHandleUpdate')
    },
    // 在线编辑文书
    weboffice (userid, applyid, file) {
      console.log('file', file)
      const url = `${webofficeEdit(file.url)}&userid=${userid}&applyid=${applyid}&attachid=${file.id}`
      console.log('viewfile', url)
      window.open(url)
    },
    /**
     * 判断当前流程是子流程还是主流程
     */
    async setIsMainProcess () {
      // 审理或受理
      if (this.category == 'hear' || this.category == 'accept') {
        this.isMainProcess = true
      } else {
        this.isMainProcess = false
      }
      if (this.isMainProcess) {
        await this.getLastChildAdmreAudit()
      } else {
        await this.getChildAdmreAudit()
      }
    },
    /**
     * 获取子流程的流程数据
     */
    async getChildAdmreAudit () {
      const childApplyId = this.$route.params.applyid
      const res = await viewApl_admre_audit(childApplyId)
      if (res.code == 0) {
        this.childAdmreAudit = res.data
        this.isCitymanager = (this.childAdmreAudit && this.childAdmreAudit.iscitymanager) ? this.childAdmreAudit.iscitymanager : 3201
      } else {
        console.log('查询子流程记录失败')
      }
    },
    /**
     * 获取最新的子流程数据
     */
    async getLastChildAdmreAudit () {
      const res = await getLastChildAudit(this.applyid, Number(this.busiKey))
      if (res.code == 0) {
        this.childAdmreAudit = res.data
        this.isCitymanager = (this.childAdmreAudit && this.childAdmreAudit.iscitymanager) ? this.childAdmreAudit.iscitymanager : 3201
      } else {
        console.log('查询最新的子流程记录失败')
      }
    },
    /**
     * 修改被申请人
     * @param {} e
     */
    citymanagerChange (e) {
      this.isCitymanager = e.target.value
      if (!this.isMainProcess) {
        updatesIscitymanager(this.applyid, this.isCitymanager).then((res) => {
          if (res.code !== 0) {
            console.log('更新是否市领导审批字段失败')
          } else {
            console.log('更新是否市领导审批字段成功')
            this.resetMaterialType()
          }
        })
      } else {
        this.resetMaterialType()
      }
    },
    initTypeEnum () {
      this.typeEnum = {}
      for (const key in this.Tp_proctypeEnum) {
        if (this.Tp_proctypeEnum[key].value === this.busiKey) {
          this.typeEnum = this.Tp_proctypeEnum[key]
        }
      }
      console.log('当前类型', this.typeEnum)
      this.labelTitle = this.typeEnum.name
      this.busiType = this.typeEnum.value
      this.busiName = this.typeEnum.key
      this.showCitymanager = this.typeEnum.showCitymanager
    },
    async resetMaterialType () {
      const _this = this
      // 通过传入的类型来获取对应的数据
      this.fileItem = []
      // this.typeEnum = {}
      // for (const key in this.Tp_proctypeEnum) {
      //   if (this.Tp_proctypeEnum[key].value === this.busiKey) {
      //     this.typeEnum = this.Tp_proctypeEnum[key]
      //   }
      // }
      // console.log('当前类型', this.typeEnum)
      // this.labelTitle = this.typeEnum.name
      // let material = JSON.parse(JSON.stringify(this.typeEnum.material))
      // this.busiType = this.typeEnum.value
      // this.busiName = this.typeEnum.key
      let material = []
      if (this.typeEnum && this.typeEnum.material) {
        material = JSON.parse(JSON.stringify(this.typeEnum.material))
      }
      if (this.showCitymanager && this.isCitymanager == 3200) { // 需要市领导审批
        material = Object.assign(material, Tp_procmaterial_decision_asynapprove)
      }
      // else {
      //   if (material[Tp_procmaterial_decision_asynapprove.hear_asynapprove]) {
      //     delete material[Tp_procmaterial_decision_asynapprove.hear_asynapprove]
      //   }
      // }
      this.setButtonDisabled()
      for (const index in material) {
        const fileItem = {
          fileName: material[index].name,
          fileType: material[index].value,
          isMultiUpload: true,
          fileList: [],
          required: material[index].required,
          isCustomer: false,
          isSaved: true,
          isUpdated: false,
        }
        this.fileItem.push(fileItem)
      }
      // 查询对应applyid的自定义材料类型
      const res = await queryCustomerMaterialByApplyid({
        applyid: this.applyid
      })
      // 查询对应applyid的表单生成材料类型
      // this.queryMaterialOptionList()
      if (res.code == 0) {
        const customerMaterials = res.data
        for (const index in customerMaterials) {
          // 如果当前的自定义材料的类型和当前的业务类型一直才展示该自定义类型材料
          this.customerMaterials = customerMaterials.filter(item => item.proctype == this.busiType)
          if (customerMaterials[index].proctype == this.busiType) {
            const customerFileItem = {
              fileName: customerMaterials[index].name,
              fileType: Tp_procmaterialValue.MATER_CUSTOMER,
              replyCustomerId: customerMaterials[index].id,
              isMultiUpload: true,
              fileList: [],
              required: false,
              isCustomer: true,
              isSaved: true,
              isUpdated: false,
              sortnum: customerMaterials[index].sortnum
            }
            this.fileItem.push(customerFileItem)
          }
        }
      } else {
        console.log('查询自定义材料错误...')
      }
      this.queryMaterialsList()
    },
    /**
     * 流程点击
     */
    startBusinessProcedClick () {
      let typeEnum
      for (const key in Tp_proctypeEnum) {
        if (Tp_proctypeEnum[key].value === this.busiKey) {
          typeEnum = Tp_proctypeEnum[key]
        }
      }
      const busiName = typeEnum ? typeEnum.key : ''
      const confirmTitile = '是否发起' + typeEnum.name + '审批?'
      this.$confirm({
        title: '提示',
        content: confirmTitile,
        onOk: () => {
          this.startBusinessProced(busiName, typeEnum)
        }
      })
    },
    /**
     * 启动流程
     * @param {} busiName
     * @param {*} describe
     */
    startBusinessProced (busiName, typeEnum) {
      passRecordExecute(this.applyid, typeEnum.categoryKey).then((res) => {
        if (res.data.code != 0) {
          this.$message.warning(res.data.msg)
          return
        } else {
          // 启动流程
          const flowParams = {
            applyid: this.applyid, // applyid
            proctype: busiName, // 操作分类
            userid: this.currentUser.userId,
            username: this.currentUser.fullname,
            processinstanceid: this.processinstanceid, // 流程实例id
            cause: '', // 案由
            describe: typeEnum.name + '申请'
          }
          const docfield = {}
          if (this.showCitymanager) {
            docfield.isCitymanager = this.isCitymanager
          }
          this.processLoading = true
          console.log('流程入参', flowParams)
          startBusinessProced(flowParams, docfield).then((res) => {
            this.processLoading = false
            if (res.code !== 0) {
              this.$message.error('操作失败')
            } else {
              this.$message.success('操作成功')
              this.$emit('reload')
              this.$emit('close')
              this.modalVisible = false
              // 暂时隐藏流程跳转
              this.autoToSonRouter(res.data, busiName)
            }
          })
        }
      })
    },
    /**
     * 路由重新定向加载
     * @param {} taskid
     */
    autoToSonRouter (res, busiName) {
      const taskid = res.taskid
      const childPprocessinstanceid = res.processinstanceid
      const params = {
        applyid: this.applyid, // applyid
        proctype: busiName, // 操作分类
        userid: this.currentUser.userId,
        username: this.currentUser.fullname,
        processinstanceid: this.processinstanceid, // 流程实例id,
        taskid: taskid,
        pattern: '3'
      }
      // 受理
      if (Tp_accept.includes(this.busiType)) {
        // // 受理
        this.$router.replace({
          // 默认3 操作模式
          query: {
            path: `/AppeptExamineHandleOperation/${taskid}/3`,
            url: '/AppeptExamineHandle',
            queryParam: params
          }
        }, () => {
          this.reload() // 刷新页面
        })
      } else if (Tp_execute.includes(this.busiType)) {
        // 执行
        // 查询当前的子流程applyid
        getByInstids(childPprocessinstanceid).then(res => {
          if (res.code == 0) {
            params.applyid = res.data.id
          }
          let typeEnum
          for (const key in Tp_proctypeEnum) {
            if (Tp_proctypeEnum[key].value === this.busiKey) {
              typeEnum = Tp_proctypeEnum[key]
            }
          }
          params.category = typeEnum.categoryKey
          params.isExecute = true
          params.isExecuteEdit = true
          this.$router.replace({
            // 默认3 操作模式
            query: {
              path: `/HearExamineProcessedOperation/${taskid}/3`,
              url: '/HearExamineHandle',
              queryParam: params
            }
          }, () => {
            this.reload() // 刷新页面
          })
        })
      } else {
        // 审理
        params.isExecute = true
        params.isExecuteEdit = true
        this.$router.replace({
          // 默认3 操作模式
          query: {
            path: `/HearExamineProcessedOperation/${taskid}/3`,
            url: '/HearExamineHandle',
            queryParam: params
          }
        }, () => {
          this.reload() // 刷新页面
        })
      }
    },

    /**
     * 查询对应的applyid下有多少材料文件
     */
    queryMaterialsList () {
      this.queryParam.applyid = this.applyid
      const _this = this
      this.spinning = true
      getAllMaterialByApplyId(this.queryParam)
        .then(res => {
          // console.log('表格数据:', res.data)
          const records = res.data
          this.allFileList = records
          // 根据对应的分类进行赋值
          this.filteFile(this.busiType)
          this.setButtonDisabled()
          console.log('材料文件', _this.fileItem)
        })
        .catch(err => {
          console.log(err, '获取数据失败')
        })
        .finally(() => {
          this.spinning = false
        })
    },
    versionView (fileItem) {
      this.$nextTick(() => {
        this.$refs.materialVersionRef.init(fileItem)
      })
    },

    filteFile (busiType) {
      // 根据对应的分类进行赋值
      for (let index = 0; index < this.fileItem.length; index++) {
        this.fileItem[index].fileList = []
        // 设置普通材料类型
        if (this.allFileList != null && this.allFileList.length > 0) {
          for (const record of this.allFileList) {
            if (!this.fileItem[index].isCustomer) {
              // 普通的材料
              if (record.mattype == this.fileItem[index].fileType && record.type == this.busiType) {
                const fileDetail = record.file
                fileDetail.materialId = record.id
                fileDetail.name = fileDetail.filename
                fileDetail.status = 'done'
                fileDetail.uid = fileDetail.id
                fileDetail.url = fileDetail.path
                fileDetail.isEditor = false
                this.fileItem[index].fileList.push(fileDetail)
              }
            } else {
              // 自定义材料
              if (record.type == busiType && record.reply_attachid == this.fileItem[index].replyCustomerId) {
                const fileDetail = record.file
                fileDetail.materialId = record.id
                fileDetail.name = fileDetail.filename
                fileDetail.status = 'done'
                fileDetail.uid = fileDetail.id
                fileDetail.url = fileDetail.path
                fileDetail.isEditor = false
                fileDetail.reply_attachid = record.reply_attachid
                this.fileItem[index].fileList.push(fileDetail)
              }
            }
          }
        }
      }
    },
    // activeBtnClick() {
    //   this.$refs.component.init()
    // },
    // 查询当前的applyid下是自己表单绑定生成的文件
    async queryMaterialOptionList () {
      await findAllOptionsByApplyid({
        applyid: this.applyid
      }).then(res => {
        if (res.code == 0) {
          this.materialOptionList = res.data
        } else {
          console.log('查询表单生成的材料文件报错...')
        }
      })
    },

    // 附件在线预览
    fileView (file) {
      console.log('文件预览', file)
      window.open(kkfilePreview(file.url))
    },
    /**
     * 编辑文件
     */
    editFile (file) {
      const findOne = this.materialOptionList.some(element => element.materialid == file.materialId)
      if (findOne) {
        // 进行编辑
        this.selectedOption = this.materialOptionList.find(element => element.materialid == file.materialId)
        this.$nextTick(() => {
          this.$refs.updateComponent.init()
        })
      } else {
        this.$message.warning('当前文件无法编辑')
      }
    },
    // 下载文件
    downloadFile (file) {
      var x = new XMLHttpRequest()
      x.open('GET', file.url, true)
      x.responseType = 'blob'
      x.onload = function (e) {
          var url = window.URL.createObjectURL(x.response)
          var a = document.createElement('a')
          a.href = url
          a.download = file.filename
          a.click()
      }
      x.send()
    },

    /**
     * 上传导入文件前验证文件类型
     */
    beforeUpload (file) {
      return new Promise((resolve, reject) => {
        // 文件格式是否为doc、docx
        const isAcceptType = file.name.toLowerCase().substr(file.name.lastIndexOf('.'))
        if (!(this.acceptFileType.indexOf(isAcceptType) > -1)) {
          this.$message.warning('请上传' + this.acceptFileType + '格式文件')
          return reject(false)
        }
        // 文件小于20M
        const isLtSize = file.size / 1024 / 1024 < FILESIZE
        if (!isLtSize) {
          this.$message.warning('请上传' + FILESIZE + 'MB以内的文件')
          return reject(false)
        }
        return resolve(false)
      })
    },

    /**
     * 上传材料的接口
     */
    uploadMaterial (data) {
      const param = {
        applyid: this.applyid,
        fileType: data.data.fileType,
        busiType: this.busiType,
        userId: this.currentUser.userId,
        userName: this.currentUser.fullname
      }
      this.loading = true
      this.isMultiUpload = data.data.isMultiUpload
      this.spinning = true
      if (this.isMultiUpload) {
        saveMaterialRepeat(param, data.file)
          .then(res => {
            if (res.code !== 0) {
              this.$message.error(res.msg)
            } else {
              this.queryMaterialsList()
            }
          })
          .catch(err => {
            console.log(err, '上传数据失败')
          })
          .finally(() => {
            this.loading = false
            setTimeout(() => {
              this.spinning = false
            }, 50)
          })
      } else {
        saveMaterial(param, data.file)
          .then(res => {
            if (res.code !== 0) {
              this.$message.error(res.msg)
            } else {
              this.queryMaterialsList()
            }
          })
          .catch(err => {
            console.log(err, '上传数据失败')
          })
          .finally(() => {
            this.loading = false
            setTimeout(() => {
              this.spinning = false
            }, 50)
          })
      }
    },
    // 上传自定义材料
    uploadMaterialCustomer (data) {
      const param = {
        applyid: this.applyid,
        fileType: data.data.fileType,
        busiType: this.busiType,
        userId: this.currentUser.userId,
        userName: this.currentUser.fullname,
        replyCustomerId: data.data.replyCustomerId
      }
      this.loading = true
      this.spinning = true
      saveMaterialCustomer(param, data.file)
        .then(res => {
          if (res.code !== 0) {
            this.$message.error(res.msg)
          } else {
            this.queryMaterialsList()
          }
        })
        .catch(err => {
          console.log(err, '上传数据失败')
        })
        .finally(() => {
          this.loading = false
          setTimeout(() => {
            this.spinning = false
          }, 50)
        })
    },
    handleRemove (data) {
      // 弹出确认框是否删除该文件
      if (this.uploadBtnShow) {
        this.$confirm({
          title: '提示',
          content: '确定删除该文件吗？',
          onOk: () => {
            const param = {
              materialId: data.materialId
            }
            this.loading = true
            this.spinning = true
            deleteMaterial(param)
              .then(res => {
                if (res.code !== 0) {
                  this.$message.error(res.msg)
                } else {
                  this.queryMaterialsList()
                }
              })
              .catch(err => {
                console.log(err, '获取数据失败')
              })
              .finally(() => {
                this.loading = false
                setTimeout(() => {
                  this.spinning = false
                }, 50)
              })
          }
        })
      } else {
        return false
      }
    },
    reloadComponent () {
      this.$emit('reload')
      // 查询对应applyid的表单生成材料类型
      this.queryMaterialOptionList()
      this.queryMaterialsList()
    },

    // 新增自定义材料
    addCustomerMaterial () {
      // 判断当前是否有未保存的自定义材料
      if (this.fileItem.filter(item => item.isCustomer).some(item => !item.isSaved)) {
        this.$message.warning('当前有未保存的自定义材料项')
        return
      }
      // 新增一项未保存的材料项
      const customerFileItem = {
        fileName: '自定义材料',
        fileType: Tp_procmaterialValue.MATER_CUSTOMER,
        replyCustomerId: '',
        isMultiUpload: true,
        fileList: [],
        required: false,
        isCustomer: true,
        isSaved: false,
        isUpdated: false,
        sortnum: 0
      }
      this.fileItem.push(customerFileItem)
    },
    editCustomerMaterial (item) {
      const element = this.fileItem.filter(el => el.replyCustomerId == item.replyCustomerId)[0]
      element.fileNameBack = element.fileName
      element.isUpdated = true
    },
    // 撤销当前的保存
    rollBackCustomerMaterial (item) {
      // 将当前的那条临时数据删除
      // 修改中的数据
      if (item.isUpdated) {
        const element = this.fileItem.filter(el => el.replyCustomerId == item.replyCustomerId)[0]
        element.fileName = element.fileNameBack
        element.isUpdated = false
      } else {
        this.fileItem = this.fileItem.filter(el => {
          if (!el.isCustomer) {
            return true
          } else {
            if (el.replyCustomerId != item.replyCustomerId) {
              return true
            }
          }
        })
      }
    },
    /**
     * 保存自定义材料类型
     * @param {} item
     */
    saveCustomerMaterial (item) {
      // 构造保存对象：
      // 判断材料项名称是否为空
      if (item.fileName == '') {
        this.$message.warning('自定义材料名称不能为空')
        return
      }
      const saveObj = {
        id: nanoid(),
        applyid: this.applyid,
        name: item.fileName,
        describe: item.fileName,
        proctype: this.busiType
      }
      if (item.isUpdated) {
        saveObj.id = item.replyCustomerId
        saveObj.sortnum = item.sortnum
      }
      saveCustomer(saveObj).then(res => {
        if (res.code == 0) {
          this.$message.success('保存自定义材料成功')
          if (!item.isUpdated) {
            // 如果是新增则重新查询数据
            // 新增一条数据
            // this.resetMaterialType();
            const customerMaterial = res.data
            const customerFileItem = {
              fileName: customerMaterial.name,
              fileType: Tp_procmaterialValue.MATER_CUSTOMER,
              replyCustomerId: customerMaterial.id,
              isMultiUpload: true,
              fileList: [],
              required: false,
              isCustomer: true,
              isSaved: true,
              isUpdated: false,
              sortnum: customerMaterial.sortnum
            }
            this.fileItem = this.fileItem.filter(element => element.isSaved)
            this.fileItem.push(customerFileItem)
          } else {
            const element = this.fileItem.filter(el => el.replyCustomerId == item.replyCustomerId)[0]
            element.isUpdated = false
          }
        } else {
          this.$message.error('保存自定义材料失败')
        }
      })
    },
    /**
     * 删除自定义材料项
     */
    deleteCustomer (item) {
      deleteCustomer({
        id: item.replyCustomerId
      }).then(res => {
        if (res.code == 0) {
          this.$message.success('删除自定义材料项成功')
          this.resetMaterialType()
        } else {
          this.$message.error('删除自定义材料项失败')
        }
      })
    },

    // 文件导入模态框展示方法
    showUploadModal (config, isCustomer) {
      this.$refs.multiUploadProduce.init(config, isCustomer)
    }
  }
}
